﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace formworks.old
{
    /// <summary>
    /// 约束类型的自定义属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class Constraints : Attribute
    {
        /// <summary>
        /// 键值类型
        /// </summary>
        public enum Types
        {
            PrimaryKey,
            ForeignKey,
        }

        /// <summary>
        /// 约束类型的自定义属性
        /// </summary>
        /// <param name="keyType">约束键类型</param>
        /// <param name="keyName">名称</param>
        /// <param name="keyValue">键值</param>
        /// <param name="references">外键引用的表的键</param>
        public Constraints(Types keyType,
            string keyName,
            string keyValue,
            string refEntity,
            string references)
        {
            this.keyType = keyType;
            this.keyName = keyName;
            this.keyValue = keyValue;
            this.refEntity = refEntity;
            this.references = references;
        }

        /// <summary>
        /// 键类型
        /// </summary>
        public Types keyType { get; set; }

        /// <summary>
        /// 键名字例如：
        /// FK_ProductOutStock_AccessTypeID
        /// </summary>
        public string keyName { get; set; }

        /// <summary>
        /// 键值例如：
        /// AccessTypeID
        /// </summary>
        public string keyValue { get; set; }

        /// <summary>
        /// 外键用的实体名例如：
        /// TB_AccessType
        /// </summary>
        public string refEntity { get; set; }

        /// <summary>
        /// 外键引用的完整信息符串例如：
        /// REFERENCES ComYeeMS.dbo.TB_AccessType (ID)
        /// </summary>
        public string references { get; set; }

    }//end class
}//end namespace
